﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;

namespace OracleCommandVisualizer
{
    public partial class VisualizerForm : Form
    {
        private XDocument doc = null;
        public VisualizerForm(XDocument xmlDoc)
        {
            InitializeComponent();
            doc = xmlDoc;
        }

        private void VisualizerForm_Load(object sender, EventArgs e)
        {
            rtbCmdText.Text =
                doc.Root.Element("CommandText").Value;
            DataTable t = new DataTable();
            t.Columns.Add("No", typeof (int));
            t.Columns.Add("Name", typeof (string));
            t.Columns.Add("DbType", typeof (string));
            t.Columns.Add("OracleType", typeof (string));
            t.Columns.Add("Value", typeof (string));
            foreach (XElement p in doc.Root.Element("Parameters").Elements())
                t.Rows.Add(
                    p.Attribute("No").Value, 
                    p.Attribute("Name").Value, 
                    p.Attribute("DbType").Value,
                    p.Attribute("OracleType").Value,
                    p.Value
                    );
            gvProperties.AutoGenerateColumns = false;
            gvProperties.DataSource = t;
        }

    }
}
